package com.shuaige.paydollarapi.controller;

import com.shuaige.paydollarapi.model.CancelOrderResponse;
import com.shuaige.paydollarapi.model.PaydollarQueryResponse;
import com.shuaige.paydollarapi.model.ReturnMesResponse;
import com.shuaige.paydollarapi.service.MerchantApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MerchantApiController {

    @Autowired
    private MerchantApiService merchantApiService;

    /**
     * 查询付款状态
     *
     * @return
     */
    @RequestMapping("/api/query")
    public PaydollarQueryResponse query() {
        return merchantApiService.query("1558682399084", "000004998684");
    }

    /**
     * 取消订单
     *
     * @return
     */
    @RequestMapping("/api/cancelOrder")
    public CancelOrderResponse cancelOrder() {
        return merchantApiService.cancelOrder("1558682399084", "Void");
    }

    /**
     * 接受支付结果
     *
     * @param returnMesResponse 返回参数
     * @return
     */
    @RequestMapping("/api/receiveReturnResults")
    public String receiveReturnResults(ReturnMesResponse returnMesResponse) {
        System.out.println(returnMesResponse);
        return "OK";
    }

}
